package com.lexed.carmanager.controllor;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lexed.carmanager.service.DriverService;

import net.minidev.json.JSONObject;

/**
 * Servlet implementation class RePassword
 */
public class RePassword extends HttpServlet {
	
	private DriverService driverService = new DriverService();
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 获取用户id和重置后的密码字符串
		String idstr = request.getParameter("id");
		String password = request.getParameter("password");
		// 字符串参数id 转换  整形id
		int id = Integer.parseInt(idstr);
		// 调用重置密码功能
		int re = driverService.repwd(id, password);
		
		JSONObject json = new JSONObject();
		
		json.put("re", re);
		
		response.setContentType("application/json;charset=utf-8");
		response.getWriter().print(json.toJSONString());
	}

}
